<include file="public:header" />
<!--客户管理-->
<div class="pad_lr_10">

  <form name="searchform" method="get" >
    <table width="100%" cellspacing="0" class="search_form">
        <tbody>
            <tr>
                <td>
                <div class="explain_col">
                    <input type="hidden" name="g" value="admin" />
                    <input type="hidden" name="m" value="inventory" />
                    <input type="hidden" name="a" value="index" />
                    <input type="hidden" name="menuid" value="{$menuid}" />
					&nbsp;&nbsp;{:L('region_cate_name')} :                    
                        <select id="region_cate" name="regionId">
                            <option value="0">{:L('please_select')}</option>
                            {$regionMenus}
                        </select>

                    &nbsp;&nbsp;{:L('store_name')} :
                    <select name="storeId" id="store_select">
                        <option value="0">{:L('please_select_region')}</option>
                        
                    </select>
                    &nbsp;&nbsp;{:L('brand_name')} :
                    <select name="brandId">
                        <option value="0">{:L('please_select')}</option>
                        <volist name="brandList" id="val">
                            <option value="{$key}"  <if condition="$search.brandId eq $key">selected="true"</if>>{$val}</option>
                        </volist>
                    </select>                    
                    <input type="submit" name="search" class="btn" value="{:L('search')}" />                   
					
                </div>
                </td>
            </tr>
        </tbody>
    </table>
    </form>


    <div class="J_tablelist table_list" data-acturi="{:U('inventory/ajax_edit')}">
        <table width="100%" cellspacing="0">
            <thead>
            <tr>
                <th width="40"><input type="checkbox" name="checkall" class="J_checkall"></th>
                <th width="40">ID</th>
                <th> <span data-tdtype="order_by" data-field="regionId">{:L('region_name')}</span></th>
                <th><span data-tdtype="order_by" data-field="brandId">{:L('brand_name')}</span></th>
                <th><span data-tdtype="order_by" data-field="modelId">{:L('model_name')}</span></th>
                <th><span data-tdtype="order_by" data-field="storeId">{:L('store_name')}</span></th>
                <th><span data-tdtype="order_by" data-field="customerInventory">{:L('customer_inventory')}</span></th>  
                <th><span data-tdtype="order_by" data-field="salesInventory">{:L('sales_inventory')}</span></th>              
                <th width=100>{:L('operations_manage')}</th>
            </tr>
            </thead>
    	    <tbody>
            <volist name="list" id="val" >
            <tr>
                <td align="center"><input type="checkbox" class="J_checkitem" value="{$val.id}"></td>
                <td align="center" width="20">{$val.id}</td>
                <td align="center">{$val['region']['name']}</td>               
                <td align="center">{$brandList[$val['brandId']]}</td>
                <td align="center">{$val['model']['name']}</td> 
                <td align="center">{$val['store']['name']}</td>                 
                <td align="center"><span data-tdtype="edit" data-field="customerInventory" class="tdedit" data-id="{$val.id}">{$val.customerInventory}</span></td>
                <td align="center">{$val.salesInventory}</td> 
                <td align="center">
                    <a href="javascript:;" class="J_showdialog" data-uri="{:U('inventory/edit', array('id'=>$val['id'],'regionId'=>$val[regionId]))}" data-title="{:L('edit')} - {$val.name}"  data-id="edit" data-width="500" data-height="200">{:L('edit')}</a> | 
                    <a href="javascript:;" class="J_confirmurl" data-acttype="ajax" data-uri="{:U('inventory/delete', array('id'=>$val['id']))}" data-msg="{:sprintf(L('confirm_delete_one'))}">{:L('delete')}</a>
                </td>
            </tr>
            </volist>
    	   </tbody>
        </table>
    </div>
    <div class="btn_wrap_fixed">
		<label class="select_all mr10"><input type="checkbox" name="checkall" class="J_checkall">{:L('select_all')}/{:L('cancel')}</label>
    	<input type="button" class="btn" data-tdtype="batch_action" data-acttype="ajax" data-uri="{:U('inventory/delete')}" data-name="id" data-msg="{:L('confirm_delete')}" value="{:L('delete')}" />
		<div id="pages">{$page}</div>
    </div>
</div>
<include file="public:footer" />
<script>
$(document).ready(function(){
    $("#region_cate").change(function(){
       var _this = $(this);
       var region_id = _this.val();
       var ajax_get_region = "{:U('store/getStoreList')}";
       var store_id = "{$search.storeId}";
       if(region_id){
        $.ajax({
            url:ajax_get_region,
            data:"region_id="+region_id,
            dataType:"json",
            success:function(data){
                if(data.status==1){
                    var str = '<option value="0">'+lang.please_select+'</option>';
                    for(d in data.data){
                        var is_select = '';
                        if(d==store_id){
                            is_select = 'selected="true"';
                        }
                        str +='<option value="'+d+'" '+is_select+'>'+data['data'][d]+'</option>';
                    }
                    $("#store_select").html(str);
                }
            }
        });
        
       }         
    });
    
 $("#region_cate").change();   
    
});

</script>
</body>
</html>